package sh.wn36.vehiclemanage.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import sh.wn36.vehiclemanage.entity.DrivingRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import sh.wn36.vehiclemanage.vo.driverInfo;
import sh.wn36.vehiclemanage.vo.driverRecordInfo;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xk
 * @since 2021-04-26
 */

@Service
public interface DrivingRecordMapper extends BaseMapper<DrivingRecord> {

    @Select("SELECT dr.*, c.car_no ,driver.`name` driverName,d.text deptName,q.rname createrName\n" +
            " FROM driving_record dr \n" +
            "LEFT JOIN car c on dr.CAR_ID = c.id \n" +
            "LEFT JOIN dictionary d on dr.DEPT_ID = d.id \n" +
            "LEFT JOIN driver on driver.id = dr.DRIVER_ID\n" +
            "LEFT JOIN q_users q on q.id = dr.CREATE_UID \n" +
            "WHERE dr.BACKTIME is null ${ew.customSqlSegment}")
    IPage<driverRecordInfo> getAll1(Page<driverRecordInfo> page, @Param(Constants.WRAPPER) QueryWrapper<driverRecordInfo> wrapper);

    @Select("SELECT dr.*, c.car_no ,driver.`name` driverName,d.text deptName,q.rname createrName\n" +
            " FROM driving_record dr \n" +
            "LEFT JOIN car c on dr.CAR_ID = c.id \n" +
            "LEFT JOIN dictionary d on dr.DEPT_ID = d.id \n" +
            "LEFT JOIN driver on driver.id = dr.DRIVER_ID\n" +
            "LEFT JOIN q_users q on q.id = dr.CREATE_UID ${ew.customSqlSegment}")
    IPage<driverRecordInfo> getAll2(Page<driverRecordInfo> page, @Param(Constants.WRAPPER)QueryWrapper<driverRecordInfo> wrapper);
}
